gc()
##          used (Mb) gc trigger (Mb) max used (Mb)
## Ncells 468544 25.1    1005840 53.8   665714 35.6
## Vcells 875351  6.7    8388608 64.0  1819492 13.9
rm(list=ls())
library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.1 ──
## ✓ ggplot2 3.3.5     ✓ purrr   0.3.4
## ✓ tibble  3.1.6     ✓ dplyr   1.0.7
## ✓ tidyr   1.1.4     ✓ stringr 1.4.0
## ✓ readr   2.1.1     ✓ forcats 0.5.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
library(plotly)
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
library(reticulate)
library(ade4)
library(reticulate)
library(htmltools)
library('Ternary')
setwd(dir = "/scratch/anissa.el/ImmuneStates/")

Tregs cells phenotypes

NBCELLTYPES = 17
CELLTYPES <- c('CD8-T', 'Other immune', 'DC / Mono', 'CD3-T', 'B', 'NK', 'Keratin-positive tumor', 'Tumor','CD4-T', 'Mesenchymal-like', 'Macrophages', 'Endothelial', 'Tregs', 'Unidentified', 'DC', 'Mono / Neu','Neutrophils')
MarkersCellsTMENS <- readRDS("./markers_cells_tmens.rds")
selectedMarkers <- readRDS("./selected_markers_cells.rds")

3D ternary plots

#### CD4-T
#,results = 'asis'
#CellTypes.toPlot <- unique(selectedMarkers[["cell_type"]])
library('IRdisplay')

Markers.toPlot <-selectedMarkers%>%filter(cell_type == "Tregs")%>%pull(marker)
# PlotsList <- list()
# PlotsList <- lapply(Markers.toPlot, function(marker1){
#   fig <- plot_3D_ternary_cell_markers("CD4-T", marker1)
#   print(htmltools::tagList(fig))
#   #cat(as.character(htmltools::tagList(fig)))#,browse=TRUE
#   #htmlwidgets::saveWidget(fig,"fig1.html")
#   #htmltools::html_print(fig)
# })

plot_3D_ternary_cell_markers("Tregs", Markers.toPlot[1])
  0%      10%      50%      80%      99% 

0.84528 4.17440 9.09330 14.42200 26.45400

## Warning in RColorBrewer::brewer.pal(N, "Set2"): minimal value for n is 3, returning requested palette with 3 different levels

## Warning in RColorBrewer::brewer.pal(N, "Set2"): minimal value for n is 3, returning requested palette with 3 different levels
plot_3D_ternary_cell_markers("Tregs", Markers.toPlot[2])
##        0%       10%       50%       80%       99% 
## -0.086878 -0.086878 -0.086878 -0.086878 18.010600
## Warning in RColorBrewer::brewer.pal(N, "Set2"): minimal value for n is 3, returning requested palette with 3 different levels

## Warning in RColorBrewer::brewer.pal(N, "Set2"): minimal value for n is 3, returning requested palette with 3 different levels
plot_3D_ternary_cell_markers("Tregs", Markers.toPlot[3])
##       0%      10%      50%      80%      99% 
## -0.03418 -0.03418 -0.03418 -0.03418 18.25640
## Warning in RColorBrewer::brewer.pal(N, "Set2"): minimal value for n is 3, returning requested palette with 3 different levels

## Warning in RColorBrewer::brewer.pal(N, "Set2"): minimal value for n is 3, returning requested palette with 3 different levels